package com.boot.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class R<T> {

    //响应码
    private Integer code;

    //返回详情
    private String msg;

    //返回数据
    private T data;

    public static <T> R success(T data){
        return new R().setCode(200)
                .setMsg("操作成功！").setData(data);
    }

    public static R fail(Integer code ,String msg){
        return new R().setCode(code).setMsg(msg);
    }
}
